home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: Function Prototype placement in source files
- Date: 16 Feb 1996 15:55:41 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Feb16085541@qcd.lanl.gov>
- References: <4g0obg$78b@barad-dur.nas.com>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: gldnspud@kali.nas.com's message of Fri, 16 Feb 1996 01:58:30 GMT
-
- In article <4g0obg$78b@barad-dur.nas.com> gldnspud@kali.nas.com (Matt
- Scott) writes:
- <snip>
- main()
- {
- float x;
- float one(void); /* 1 */
- void two(void); /* 2 */
- <snip>
- My question is this: is there a compelling reason not to prototype
- functions above all of the functions using it, such as:
-
- On the contrary.
-
- <snip>
- In almost every instance of prototypes I've seen, they are declared
- outside of any function -- mostly above all other functions, and in
- a header file most often.
-
- The greatest advantage fo putting it in a header file is that you can
- make sure that _exactly_ the same declaration is included at function
- definition time and function use time. So, if the definition doesn't
- match use, it shall be reported.
-
- Is there a good reason to do it the way he and the book do it?
-
- Can't think of any. Probably the mentality of thinking of a function
- as a unit, rather than an entire compilation unit at a time. I think
- that is a mistake: it is good practice to use compilation units in the
- same way as modules of other languages, or even smaller units.
-
- Thanks in advance for any thoughtful answers.
-
- Sorry, couldn;t find any useful thoughts.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-